﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Chapter04
{
    public class Code03
    {
        public static void Begin()
        {
            {
                int myInteger = 25;
                string resultString = (myInteger < 10) ? "Less than 10" : "Greater than or equal to 10";
            }
            {
                string resultString;
                int myInteger = 9;
                if (myInteger < 10)
                    resultString = "Less than 10";
                else
                    resultString = "Greater than or equal to 10";
                Console.WriteLine(resultString);
            }
            {
                var var1 = 3;
                if (var1 == 1)
                {

                }
                else
                {
                    if (var1 == 2)
                    {

                    }
                    else
                    {
                        if (var1 == 3 || var1 == 4)
                        {

                        }
                        else
                        {

                        }
                    }
                }
            }
            {
                var var1 = 0;
                if (var1 == 1)
                {

                }
                else if (var1 == 2)
                {

                }
                else if (var1 == 3 || var1 == 4)
                {

                }
                else
                {

                }
            }
        }

        public static void BeginEx02()
        {
            string compartion;
            Console.WriteLine("Enter a number;");
            double var1 = Convert.ToDouble(Console.ReadLine());
            Console.WriteLine("Enter another number:");
            double var2 = Convert.ToDouble(Console.ReadLine());
            //方式1
            if (var1 < var2)
                compartion = "less than";
            else
            {
                if (var1 == var2)
                    compartion = "equal to";
                else
                    compartion = "greater than";
            }
            Console.WriteLine("The first number is {0} the second number.", compartion);
            Console.ReadLine();

            //方式2
            if (var1 < var2)
                compartion = "less than";
            if (var1 == var2)
                compartion = "equal to";
            if (var1 > var2)
                compartion = "greater than";
            Console.WriteLine("The first number is {0} the second number.", compartion);
            Console.ReadLine();
        }

        public static void BeginEx03()
        {
            int myInteger = 2;
            switch (myInteger)
            {
                case 1:
                    break;
                case -1:
                    break;
                default:
                    break;
            }

            const int intTwo = 2;
            Console.WriteLine(intTwo);

            const string myName = "Karli";
            const string sexyName = "angelina";
            const string sillyName = "ploppy";
            string name;
            Console.WriteLine("What is your name?");
            name = Console.ReadLine();
            switch (name.ToLower())
            {
                case myName:
                    Console.WriteLine("You have the same name as me!");
                    break;
                case sexyName:
                    Console.WriteLine("My, what a sexy name you have!");
                    break;
                case sillyName:
                    Console.WriteLine("That's a very silly name!");
                    break;
            }
            Console.WriteLine("Hello {0}", name);
            Console.ReadLine();
        }
    }
}
